package com.leen.video.controller;


import com.leen.common.vo.ResponseVO;
import com.leen.common.vo.ResultEnum;
import com.leen.common.vo.ResultVO;
import com.leen.video.entity.ColumnConfig;
import com.leen.video.repository.ColumnConfigRepository;
import com.leen.video.service.ColumnConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 代码生成字段信息存储 前端控制器
 * </p>
 *
 * @author yy
 * @since 2021-05-19
 */
@RestController
@RequestMapping("/video")
public class ColumnConfigController {
    @Autowired
    ColumnConfigService columnConfigService;

    /**
     * 新增数据
     * @param columnConfig
     * @return
     */
    @PostMapping(value = "/columnconfig/add")
    public ResultVO dictAdd(@RequestBody ColumnConfig columnConfig){
        ColumnConfig save = this.columnConfigService.save(columnConfig);
        if(save!=null){
            return ResultVO.success(ResultEnum.DB_SUCCESS);
        }else {
            return ResultVO.success(ResultEnum.DB_FAILED);
        }

    }

    /**
     *
     * @return
     */
    @GetMapping(value = "/columnconfig/findall")
    public  ResultVO<ResponseVO> findAll(){
        Iterable<ColumnConfig> all = this.columnConfigService.findAll();
        return ResultVO.success(all);
    }


    @PostMapping("/columnconfig/update")
    public ResultVO update(ColumnConfig columnConfig){
        ColumnConfig save = this.columnConfigService.save(columnConfig);
        if(save!=null){
            return ResultVO.success(ResultEnum.DB_SUCCESS);
        }else {
            return ResultVO.success(ResultEnum.DB_FAILED);
        }
    }
}

